// page_yao/yao_ys/yao_ys.js
let app = getApp()
let yuming = app.globalData.yuming
const request = require('../../config/request');
let shuzong = []
Page({
    ...request,

    /**
     * 页面的初始数据
     */
    data: {
        heights: "",
        title: '未打卡说明列表',
        page: 1,
        startime: '请选择',
        endtime: '请选择',
        startimes: '',
        endtimes: '',
        yuming: yuming,
        chu_total:'',
        uid:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            heights: wx.getMenuButtonBoundingClientRect().top + 5,
            shopId: wx.getStorageSync('shopId'),
            uid: options.stid,
            yname: options.yname
        })
        console.log(options.stid);
        this.yaoshi()
    },
    backs() {
        wx.navigateBack({
            delta: 1
        })
    },
    // 时间筛选
    bindDateChange: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        this.setData({
            startime: e.detail.value,
            startimes: e.detail.value,
            page: 1
        })
        this.yaoshi()
    },
    bindDateChanges: function (e) {
        console.log('picker发送选择改变，携带值为', e.detail.value)
        if (e.detail.value < this.data.startime) {
            wx.showToast({
                title: '结束时间不能小于起始时间',
                icon: 'none'
            })
        } else {
            this.setData({
                endtime: e.detail.value,
                endtimes: e.detail.value,
                page: 1
            })
            this.yaoshi()

        }
    },
    yaoshi() {
        this.myRequest(yuming + 'Jinghexincheng/staff_nosignlog_stafflist', {
            shopId: this.data.shopId,
            page: this.data.page,
            signtime: this.data.startimes,
            endtime: this.data.endtimes,
            keywords:'',
            id:this.data.uid
        }, "POST").then(res => {
          this.setData({
            chu_total: res.data.total
        })
            if (res.data.data.length == 0) {
                wx.showToast({
                    icon: 'none',
                    title: '没有更多数据了',
                    duration: 1000
                })
            }
            if (this.data.page == 1) {
                this.setData({
                    shanghulists: res.data.data,
                })
            } else {
                this.setData({
                    shanghulists: shuzong.concat(res.data.data)
                })
            }
            console.log(this.data.shanghulists)
            console.log(res)
        })
    },
    lower: function () {
        shuzong = this.data.shanghulists
        console.log(shuzong)
        if (shuzong.length >= 10) {
            this.setData({
                page: this.data.page + 1
            })
            wx.showLoading({
                title: '加载中...'
            })
            this.yaoshi()
        }


    },
      // 预览图片
  fangdaimg(e) {
    var url = e.currentTarget.dataset.url
    console.log('点击了放大！')
    wx.previewImage({
        urls: [url]
    })
},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },


})